package com.example.yiwei.crm.util;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;

import android.text.TextUtils;
import android.util.Log;

public class NetWorkUtils {
	public static String getCount(String url,String parms){
		String result = "";
		BufferedReader reader = null;
		try {
			URL mURL=new URL(url);
			HttpURLConnection conn=(HttpURLConnection) mURL.openConnection();
			conn.setDoInput(true);
			conn.setDoOutput(true);
			conn.setUseCaches(true);
			conn.setRequestMethod("POST");
			if(!TextUtils.isEmpty(parms)){
				StringBuffer buffter = new StringBuffer();
				buffter.append("list=").append(parms);
				conn.getOutputStream().write(buffter.toString().getBytes());
			}

			reader=new BufferedReader(new InputStreamReader(conn.getInputStream()));
			String len;
			while((len=reader.readLine())!=null){
				result = len;
			}
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();

		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			try {
				if (reader != null) {
					reader.close();
				}
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		return result;

	}
}
